import actionType from './actiontype'

import {
    getNotfinish
} from '../requests'


const readnotestart = () => {
    return {
        type: actionType.READNOTESTART
    }
}
const readnotefinish = () => {
    return {
        type: actionType.READNOTEFINISH
    }
}


export const getadminnote = () => {
    return (dispatch) => {
        getNotfinish().then((res) => {
            const datas = res.data
            dispatch({
                type: actionType.GETADMINNOTE,
                payload: {
                    datas
                }
            })

        })
    }



}

export const readnote = (id) => {


    return (dispatch) => {
        dispatch(readnotestart())
        setTimeout(() => {
            dispatch({
                type: actionType.READNOTE,
                payload: {
                    id
                }
            })
            dispatch(readnotefinish())
        }, 1000);
    }


}
export const allreadnote = (id) => {


    return (dispatch) => {
        dispatch(readnotestart())
        setTimeout(() => {
            dispatch({
                type: actionType.ALLREADNOTE,

            })
            dispatch(readnotefinish())
        }, 1000);
    }


}

export const readnoteasync = (id) => {
    return (dispatch) => {
        setTimeout(() => {
            dispatch(readnote(id))
        }, 1000);
    }


}